home *** CD-ROM | disk | FTP | other *** search
- Path: camelot.dsccc.com!not-for-mail
- From: kcline@sun132.spd.dsccc.com (Kevin Cline)
- Newsgroups: comp.lang.c++
- Subject: Re: Abend caused by "strcmp"
- Date: 24 Jan 1996 10:45:00 -0600
- Organization: DSC Communications Corporation Switch Products Division
- Message-ID: <4e5nmc$ru9@sun132.spd.dsccc.com>
- References: <4e4guc$o1u@tst.hk.super.net> <4e5n7c$rdm@sun132.spd.dsccc.com>
- NNTP-Posting-Host: sun132.spd.dsccc.com
-
- In article <4e4guc$o1u@tst.hk.super.net>,
- Judy Wong <jlcwong@hk.super.net> wrote:
- >I am using Borland C++ v4.0 & v4.5. My machine is Intel Pentium 100.
- >The program I wrote is a window program.
- >
- >In v4.5, when my program executes the statement :
- >
- > "if (strcmp(a, NULL) == 0) ..." where a is declared as
- > char *a="name";
- >
- >it abends with the following 'Unhandled Exception' error msg. :
-
- Only IBM mainframe programs "abend". PC programs crash.
- Unix programs abort or dump core.
-
- Anyway, you can't pass NULL (0) to strcmp; you must pass a pointer to
- an actual string. I can't tell whether you are trying to tell whether
- a points to an empty string, or whether a is a null pointer. To
- determine if a points to an empty string:
- if (*a == 0) // If first char is 0
- or
- if (!*a) // some like this style, some don't.
-
- To determine if a is a null pointer:
- if (a == 0)
- or
- if (!a) // some like this style, some don't.
-
- Do not use NULL in C++ programs; just use zero instead. You will also
- simplify your life if you can get a string class and use it instead of
- pointers to char.
- --
- Kevin Cline
-
-
- --
- Kevin Cline
-